package com.proj.service.impl;

import com.proj.bean.User;
import com.proj.bean.Useraddress;
import com.proj.dao.UserDao;
import com.proj.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService implements IUserService {

    @Autowired
    UserDao userDao;

    @Override
    public User getUserByUsername(String name) {
        return userDao.getUserByUsername(name);
    }

    @Override
    public User getuserById(int userid) {
        return userDao.getuserById(userid);
    }

    @Override
    public List<Useraddress> getaddress(int userid) {
        return userDao.getaddress(userid);
    }

    @Override
    public Useraddress getAddressById(int id) {
        return userDao.getAddressById(id);
    }

    @Override
    public int add(Useraddress address) {
        return userDao.add(address);
    }

    @Override
    public int edit(Useraddress address) {
        return userDao.edit(address);
    }

    @Override
    public int delete(int id) {
        return userDao.delete(id);
    }

    @Override
    public int setDefault(int id,int userid) {
        userDao.cancelDefault(userid);
        return userDao.setDefault(id);
    }

    @Override
    public int newuser(User user) {
        return userDao.newuser(user);
    }

    @Override
    public int newpass(String password, Integer userid) {
        return userDao.newpass(password,userid);
    }
}
